// nodes/StartNode.js
import { CircleNode, CircleNodeModel } from '@logicflow/core'

class StartNodeModel extends CircleNodeModel {
  initNodeData(data) {
    super.initNodeData(data)
    this.r = 30
    this.text = {
      value: '开始',
      x: data.x,
      y: data.y + 40
    }
    // 开始节点只有出边
    this.sourceRules.push({
      message: '开始节点只能连接出边',
      validate: (sourceNode, targetNode, sourceAnchor, targetAnchor) => {
        return targetNode.type !== 'start-node'
      }
    })
  }
  
  getNodeStyle() {
    const style = super.getNodeStyle()
    style.fill = '#FFA500'
    style.stroke = '#FF8C00'
    return style
  }
}

class StartNodeView extends CircleNode {}

export default {
  type: 'start-node',
  view: StartNodeView,
  model: StartNodeModel
}